home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 118 / cd-rom 118.iso / aplic / open / openofficeorg1.cab / ShowInfoDialog.xba < prev    next >
Encoding:
Extensible Markup Language  |  2004-05-19  |  10.2 KB  |  306 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="ShowInfoDialog" script:language="StarBasic">REM  *****  BASIC  *****
  4. Dim oWnd As Object
  5. Dim oWnd2 As Object
  6. Dim oWnd3 As Object
  7. Dim oDoc as Object
  8.     
  9. Sub ShowInfoMain
  10.     prop() = GetShowInfoPropeties()
  11.     Init(prop(0).Value, prop(1).Value, prop(2).Value, prop(3).Value, prop(4).Value, prop(5).Value, prop(6).Value, prop(7).Value, prop(8).Value)        
  12. End Sub
  13.  
  14. Sub Init(tFieldText As String, windowX, windowY, windowWidth, windowHeight, tFieldX, tFieldY, tFieldWidth, tFieldHeight)
  15.     toolkit = createUnoService("com.sun.star.awt.Toolkit")
  16.     Dim oWndDescr As new com.sun.star.awt.WindowDescriptor
  17.     Dim oBounds As new com.sun.star.awt.Rectangle
  18.     oWndDescr.Type = com.sun.star.awt.WindowClass.TOP
  19.     oWndDescr.WindowServiceName = ""
  20.     oWndDescr.ParentIndex = 0
  21.     
  22.     'officeX = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.X
  23.     'officeY = StarDesktop.ActiveFrame.getContainerWindow().AccessibleContext.LocationOnScreen.Y
  24.     'officeWidth  = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Width
  25.     'officeHeight = StarDesktop.ActiveFrame.getContainerWindow().getPosSize().Height
  26.     officeWidth  = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Width
  27.     officeHeight = thisComponent.CurrentController.Frame.getContainerWindow().getPosSize().Height
  28.  
  29.     'dialogWidth  = myTutoShowDialog.getPosSize().Width
  30.     'dialogHeight = myTutoShowDialog.getPosSize().Height
  31.     X = officeWidth - windowWidth - windowX
  32.     Y = officeHeight - windowHeight - windowY
  33.     
  34.     oBounds.X = X : oBounds.Y = Y
  35.     oBounds.Width = windowWidth : oBounds.Height = windowHeight
  36.     oWndDescr.Bounds = oBounds
  37.     oWndDescr.Parent = thisComponent.CurrentController.Frame.ContainerWindow
  38.     with com.sun.star.awt.WindowAttribute
  39.         oWndDescr.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
  40.     end with
  41.            
  42.     oWnd = toolkit.createWindow(oWndDescr)    
  43.  
  44.     Dim oWndDescr3 As new com.sun.star.awt.WindowDescriptor
  45.     Dim oBounds3 As new com.sun.star.awt.Rectangle
  46.     oWndDescr3.Type = com.sun.star.awt.WindowClass.TOP
  47.     oWndDescr3.WindowServiceName = "fixedimage" '"fixedtext"
  48.     oWndDescr3.ParentIndex = 0
  49.     oBounds3.X = 0 : oBounds3.Y = 0
  50.     oBounds3.Width = tFieldWidth : oBounds3.Height = tFieldHeight
  51.     oWndDescr3.Bounds = oBounds3
  52.     oWndDescr3.Parent = oWnd
  53.     with com.sun.star.awt.WindowAttribute
  54.         oWndDescr3.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
  55.     end with
  56.  
  57.     oWnd3= toolkit.createWindow(oWndDescr3)    
  58.     'oWnd2.Text = tFieldText     
  59.     'printdbgInfo(oWnd3)
  60.     setImage(oWnd3)
  61.     'oWnd3.Background = 16777215    
  62. '    oWnd2.SetBackGround(16776960)
  63.     oWnd.SetBackGround(16776960)
  64. '    oWnd.FontDescriptors(0).Name = "Albany"
  65. '    oWnd.FontDescriptors(0).StyleName = "BOLD"    
  66.  
  67.     Dim oWndDescr2 As new com.sun.star.awt.WindowDescriptor
  68.     Dim oBounds2 As new com.sun.star.awt.Rectangle
  69.     oWndDescr2.Type = com.sun.star.awt.WindowClass.TOP
  70.     oWndDescr2.WindowServiceName = "fixedtext"
  71.     oWndDescr2.ParentIndex = 0
  72.     oBounds2.X = tFieldX : oBounds2.Y = tFieldY
  73.     oBounds2.Width = tFieldWidth : oBounds2.Height = tFieldHeight
  74.     oWndDescr2.Bounds = oBounds2
  75.     oWndDescr2.Parent = oWnd3
  76.     with com.sun.star.awt.WindowAttribute
  77.         oWndDescr2.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
  78.     end with
  79.  
  80.     oWnd2= toolkit.createWindow(oWndDescr2)
  81.     oWnd2.Text = tFieldText 
  82.     oWnd2.Background = 268435455
  83.     'printdbgInfo(oWnd2)
  84.     
  85.     'printdbgInfo oWnd.getPosSize()
  86.     
  87. End Sub
  88.  
  89. Function GetShowInfoPropeties()
  90.     stepText = GetStepTitle()
  91.     Dim Properties(8) As new com.sun.star.beans.NamedValue    
  92.     Properties(0).Name = "ShowInfoDialogText"
  93.     Properties(0).Value = stepText & "Press [Esc] to abort."    
  94.     Properties(1).Name = "WindowX"
  95.     Properties(1).Value = 20        
  96.     Properties(2).Name = "WindowY"
  97.     Properties(2).Value = 40        
  98.     Properties(3).Name = "WindowWidth"
  99.     Properties(3).Value = 190    
  100.     Properties(4).Name = "WindowHeight"
  101.     Properties(4).Value = 50
  102.     Properties(5).Name = "TFieldX"
  103.     Properties(5).Value = 7
  104.     Properties(6).Name = "TFieldY"
  105.     Properties(6).Value = 8
  106.     Properties(7).Name = "TFieldWidth"
  107.     Properties(7).Value = 190
  108.     Properties(8).Name = "TFieldHeight"
  109.     Properties(8).Value = 50
  110.     GetShowInfoPropeties = Properties()    
  111. End Function
  112.  
  113. Sub setShowInfoText()
  114.     stepText = GetStepTitle()
  115.     oWnd2.Text = stepText & "Press [Esc] to abort."
  116. End Sub
  117.  
  118. Sub ShowON()
  119.     setShowInfoText()
  120.     oWnd.setVisible(True)
  121.     oWnd3.setVisible(True)    
  122.     oWnd2.setVisible(True)
  123. End Sub
  124.  
  125. Sub ShowOFF()
  126.     On Local Error Goto NOPROPERTYSETINFO:
  127.         oWnd.setVisible(False)
  128.         oWnd2.setVisible(False)
  129.         oWnd3.setVisible(False)
  130.         oDoc.dispose()
  131.     Exit Sub
  132.     NOPROPERTYSETINFO:
  133.  
  134. End Sub
  135.  
  136. Sub DisposeIDialog()
  137.     On Local Error Goto NOPROPERTYSETINFO:    
  138.         oWnd3.dispose
  139.         oWnd2.dispose
  140.         oWnd.dispose
  141.         oDoc.dispose()    
  142.     Exit Sub
  143.     NOPROPERTYSETINFO:
  144. End Sub
  145.  
  146. sub setImage(whatever as Object) 
  147.     
  148.     templatePath = GetPathSettings("Template",false, 0)
  149.     Dim bitmapPath As String
  150.     iPos = InStr(templatePath,"/")
  151.     if(iPos > 0) Then
  152.         bitmapPath = templatePath & "/wizard/bitmap/tutorial_background.gif"
  153.     Else
  154.         bitmapPath = templatePath & "\wizard\bitmap\tutorial_background.gif"
  155.     End If
  156.     
  157.     dim props(0) as new com.sun.star.beans.PropertyValue
  158.     props(0).Name = "Hidden"
  159.     props(0).Value = true
  160.     oDoc = StarDesktop.loadComponentFromUrl("private:factory/swriter","_blank",0,props())
  161.     oShape = addControlToDefaultForm("ImageButton", 1000, 1000, 2000, 1000)    
  162.     imgControl = oShape.getControl()
  163.     'imgControl.ImageUrl="file:///D:/Program%20Files/src680_m11_qwizards1_49_TEST/share/gallery/tutoItem.gif"    
  164.     imgControl.ImageUrl = bitmapPath  
  165.     imgControl.addConsumer(whatever)
  166.     imgControl.startProduction()
  167. end sub
  168.  
  169. Function createControlShape(cKind As String) As Object
  170.  
  171.     Dim oControlShape As Object
  172.     Dim oControl As Object
  173.  
  174.     
  175.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  176.     oControl = oDoc.createInstance("com.sun.star.form.component." & cKind)
  177.     oControl.setPropertyValue("DefaultControl", "com.sun.star.form.control." & cKind)
  178.     oControlShape.setControl(oControl)
  179.  
  180.  
  181.     createControlShape() = oControlShape
  182.  
  183. End Function
  184.  
  185. Function createControlShapeWithDefaultControl(cKind As String) As Object
  186.  
  187.     Dim oControlShape As Object
  188.     Dim oControl As Object
  189.  
  190.     
  191.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  192.     oControl = oDoc.createInstance("com.sun.star.form.component." & cKind)
  193.     oControlShape.setControl(oControl)
  194.  
  195.  
  196.     createControlShapeWithDefaultControl() = oControlShape
  197.  
  198. End Function
  199.  
  200. Function createUNOControlShape(cKind As String, defControl As String) As Object
  201.  
  202.     Dim oControlShape As Object
  203.     Dim oControl As Object
  204.  
  205.  
  206.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  207.     oControl = oDoc.createInstance("com.sun.star.form.component." & cKind)
  208.     oControl.setPropertyValue("DefaultControl", "com.sun.star.awt." & defControl)
  209.     oControlShape.setControl(oControl)
  210.  
  211.  
  212.     createUNOControlShape() = oControlShape
  213.  
  214. End Function
  215.  
  216. Function addShape(oShape As Object) As Boolean
  217.  
  218.     Dim vSize As New com.sun.star.awt.Size
  219.     Dim oDrawPage As Object
  220.     Dim oForms As Object
  221.     Dim oForm As Object
  222.  
  223.     oDrawPage = oDoc.getDrawPage()
  224.     oForms = oDrawPage.getForms()
  225.     
  226.     if oForms.Count = 0 then
  227.         oForm = oDoc.createInstance("com.sun.star.form.component.Form")
  228.         oForms.insertByIndex(0, oForm)
  229.     end if
  230.     
  231.     vSize.Height = 2000 : vSize.Width = 2000
  232.     oShape.Size = vSize
  233.     oDrawPage.add(oShape)
  234.  
  235.     addShape() = true
  236.  
  237. End Function
  238.  
  239. sub addControl(cKind as String)
  240.  
  241.     Dim oDrawPage As Object
  242.     Dim oForm As Object, oForms As Object
  243.     Dim oControl As Object, oControlShape As Object
  244.     Dim aSz As Variant
  245.     Dim oText As Object
  246.  
  247.     oDrawPage = oDoc.DrawPage
  248.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  249.     oControl = oDoc.createInstance("com.sun.star.form.component." + cKind)
  250.     oForm = oDoc.createInstance("com.sun.star.form.component.Form")
  251.     oforms = oDrawPage.Forms
  252.     if oforms.count = 0 then
  253.             oforms.insertbyindex(0,oForm)
  254.     end if
  255.     oControlShape.Control = oControl
  256.     oDrawPage.add(oControlShape)
  257.         
  258. End sub
  259.  
  260. Function addControlToDefaultForm(cKind as String, x As Integer, y As Integer, width As Integer, height As Integer) As Object
  261.  
  262.     Dim oDrawPage As Object
  263.     Dim oControl As Object, oControlShape As Object
  264.     Dim pos As New com.sun.star.awt.Point
  265.     Dim size As New com.sun.star.awt.Size
  266.  
  267.     pos.X = x
  268.     pos.Y = y
  269.     size.Width = width
  270.     size.Height = height
  271.     
  272.     oDrawPage = oDoc.DrawPage
  273.     oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape")
  274.     oControl = oDoc.createInstance("com.sun.star.form.component." + cKind)
  275.     oControlShape.Control = oControl
  276.     oControlShape.Position = pos
  277.     oControlShape.Size = size
  278.     oDrawPage.add(oControlShape)
  279.  
  280.     addControlToDefaultForm() = oControlShape
  281.  
  282. End Function
  283.  
  284. Function addShapeToDrawDoc(oPage as Object, nPosX, nPosY as Integer, oType As String) As Object
  285.     Dim aPoint As New com.sun.star.awt.Point
  286.     Dim aSize As New com.sun.star.awt.Size
  287.     Dim oShape As Object
  288.     Dim servNames As Variant
  289.  
  290.     aPoint.x = nPosX
  291.     aPoint.y = nPosY
  292.     aSize.Width = 2000
  293.     aSize.Height = 1000
  294.     oShape = oDoc.createInstance("com.sun.star.drawing."+oType+"Shape")
  295.     oShape.Size = aSize
  296.     oShape.Position = aPoint
  297.     
  298.     if oShape.getPropertySetInfo().hasPropertyByName("FillColor") then
  299.         oShape.FillColor = RGB(128, 255, 0)
  300.     End If
  301.  
  302.     oPage.add(oShape)
  303.  
  304.     addShapeToDrawDoc() = oShape
  305. End Function
  306. </script:module>